package com.kaifamiao.wrapper;

/**
 * 从 基本数据类型 到 包装类类型
 * 1、从 Java 9 开始已经将 八种基本数据类型 对应的包装类中的构造方法全部废弃
 * 2、使用 valueOf(primitive) 方法将相应的 基本数据类型 数值 包装到对象中
 *        Integer third = Integer.valueOf( 12345 );
 * 3、八种基本数据类型 对应的包装类中 都有一个 valueOf(primitive)
 */
public class PrimitiveToWrapper {

    public static void main(String[] args) {

        byte primitiveByte = 100;
        Byte first = Byte.valueOf( primitiveByte );
        System.out.println( first );

        short primitiveShort = 9527;
        Short second = Short.valueOf( primitiveShort );
        System.out.println( second );

        int primitiveInt = 12345;
        // 将 基本数据类型的数值 包裹到一个 Integer类型的 实例中
        Integer third = Integer.valueOf( primitiveInt );
        System.out.println( third );

        long primitiveLong = 1234567890123456789L;
        Long fourth = Long.valueOf( primitiveLong );
        System.out.println( fourth );

        float primitiveFloat = 12.34f;
        Float fifth = Float.valueOf( primitiveFloat );
        System.out.println( fifth );

        double primitiveDouble = 95.27;
        Double sixth = Double.valueOf( primitiveDouble );
        System.out.println( sixth );

        boolean primitiveBoolean = false;
        Boolean seventh = Boolean.valueOf( primitiveBoolean );
        System.out.println( seventh );

        char primitiveChar = '喵';
        Character eighth = Character.valueOf( primitiveChar );
        System.out.println( eighth );

    }

}
